var root = ui("$");
var app = sm("do_App");
var do_Page = sm("do_Page");
var nf = sm("do_Notification");
var pubUrl = require("url/pub");
var communityUtil = require("helper/community");
var httpUrl = pubUrl.url.comment.doDelete;
var qqHttp = require("helper/http");
var helperOpen = require("helper/open");
var bizzType = require("helper/bizzType");
//UI
var buttonDel=ui("buttonDel");
var labelContent=ui("labelContent");
//设置数据绑定的映射关系
root.setMapping({   // 此处的Mapping只能设置在 RootView 上 ;
	"UserName.text" : "beUserName",
    "UserPic.tag" : "beUserId",
    "UserPic.source" : "beUserFullImg",
    "labelBizzContent.text" : "bizzTitle",
    "labelContent.text" : "content",
    "labelContent.tag" : "bizzType",
    "labelTime.text" : "cnNewAt",
    "imglayout.visible" : "hasImg",
    "imgMain.source" : "imgMain",
    "contentLayout.tag" : "bizzId",
    "buttonDel.tag" : "id"
});
root.on("dataRefreshed", function(){
});
var contentLayout = ui("contentLayout");
contentLayout.on("touch",function(){
	var bizzId = contentLayout.tag;
	var type= labelContent.tag;
	if(type == bizzType.Level2.CIRCLE_TOPIC){
		helperOpen.open("source://view/circle/topic/detail/topicBorderView.ui",{topicId:bizzId});
	}else if(type == bizzType.Level2.COMMUNITY_MESSAGE){
		helperOpen.open("source://view/community/message/detail/msgBorderView.ui",{id:bizzId});
	}else if(type == bizzType.Level2.USER_TOPIC){
		
	}
	
})
buttonDel.on("touch",function(){
	nf.confirm("您确实要删除这条评论吗？", "删除", "确定", "取消", function(data, e) {
		if(data == 1){
			delMessage();
		}
	})
})
function delMessage(){
	var params = {
		id: buttonDel.tag
	};
	qqHttp.post(httpUrl, params, function(data) {
		nf.toast("删除成功");
		do_Page.fire("deleteMessage",buttonDel.tag);
	})
}